Introduction Of C Programming

Posted on October 14, 2023 by Vishesh Namdev
Python C C++ Javascript Java
C Programming Language

Welcome to our C Programming Tutorial, where you’ll entire C programming spectrum, from basic concepts like variables, arrays, pointers, and strings to more advanced topics like loops.

What is C?

C programming is a high-level, general-purpose programming language developed by Dennis Ritchie at Bell Labs in 1972. It was originally created to develop the UNIX operating system, making it a foundational language in computer science. Known for its speed and efficiency, C provides low-level access to memory and is still widely used in systems programming, embedded systems, and academic settings. Its simplicity and power continue to influence many modern programming languages.

Why learn C Programming:-

  • Highly Portable: Code written in C can run on various platforms with minimal changes.
  • Fast and Efficient: C programs are known for their high performance and low memory usage.
  • Foundation for Other Languages: Learning C makes it easier to understand languages like C++, Java, and Python.
  • Low-Level Memory Access: It allows direct manipulation of memory using pointers, essential for system-level programming.
  • Better Understanding of Computer Architecture: C helps you grasp how computers work at the hardware level, including memory management and CPU instructions.
  • Features of C

  • Procedural Language: Follows a step-by-step approach, making code easy to understand and maintain.
  • Rich Library: Offers a wide range of built-in functions to simplify programming tasks.
  • Structured Programming: Encourages the use of functions and control structures, enhancing code organization.
  • Low-Level Memory Access: Allows direct manipulation of memory using pointers, making it ideal for system-level programming.
  • Fast Execution: Produces efficient machine-level code that executes quickly.
  • Portable and Modular: Code written in C can be reused across different platforms with minimal changes.
  • How C Program Works (Compilation Flow)

    Compilation in C Programming Flow Chart

    First C Program – "Hello, World!"

    #include <stdio.h>
    
    int main() {
        printf("Hello, World!");
        return 0;
    }
  • #include <stdio.h>: This line includes the Standard Input Output library, which allows the program to use functions like printf() for displaying output.
  • int main() { ... }: This is the main function where the execution of the program begins. Every C program must have a main() function.
  • printf("Hello, World!");: This function prints the message "Hello, World!" to the screen. It is used for output in C.
  • return 0;: This statement ends the main() function and returns 0 to the operating system, indicating that the program ran successfully.
  • First C Program – "Hello, World!"

    To compile and run a C program, you need a C compiler like GCC. The steps may vary slightly depending on your operating system. Here's how you can do it:

    On Windows:

    You can use an IDE like Code::Blocks or a text editor like VS Code with the GCC compiler installed. Follow these steps:

  • Write your C code and save it with a .c extension (e.g., hello.c).
  • Install Code::Blocks or VS Code with GCC.
  • Open terminal and run:
  • gcc filename.c -o output
    ./output

    On Linux/macOS:

  • Use terminal:
  • gcc hello.c -o hello
    ./hello

    Basic Structure of a C Program

    A typical C program follows a consistent structure. Here are the main components:

  • Headers – Used to include libraries (e.g., #include <stdio.h>).
  • main function – Entry point of every C program (int main() { ... }).
  • Variable declarations – Where variables are defined before use.
  • Statements – The actual logic and operations are written here.
  • Return statement – Ends the program and returns a value (usually return 0;).
  • 🧠 Quick Quiz: Test Your C Knowledge

    ❓ 1. Who developed the C programming language?



    ❓ 2. What does printf() do?



    ❓ 3. Which header file is required for printf()?